<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateColumnToTagContentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('tag_contents', function (Blueprint $table) {
            if (Schema::hasColumn('tag_contents', 'content_id')) {
                $table->dropColumn('content_id');
            }
            if (Schema::hasColumn('tag_contents', 'content_model')) {
                $table->dropColumn('content_model');
            }
            $table->string('tag_content_type', 100)->comment('内容模型类型');
            $table->integer('tag_content_id')->default(0)->nullable()->unsigned()->comment('内容ID');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
